package game.entity;

import game.entity.mob.Mob_Group;
import game.entity.ui.UI_Group;
import game.gamestate.GameState;

import java.util.EnumMap;

import common.Log;

public class EntityManager {
	public EntityManager() {
		_EntityGroups = new EnumMap<EntityType_E, EntityGroup_I>(EntityType_E.class);
		_EntityGroups.put(EntityType_E.UI, new UI_Group());
		_EntityGroups.put(EntityType_E.MOB, new Mob_Group());
	}
	private final EnumMap<EntityType_E, EntityGroup_I> _EntityGroups;
	
	public void spawn(Entity_A entity, GameState gameState) {
		EntityGroup_I group = _EntityGroups.get(entity.Type);
		group.spawn(entity, gameState);
	}
	
	public void destroy(Entity_A entity, GameState gameState) {
		EntityGroup_I group = _EntityGroups.get(entity.Type);
		group.destroy(entity, gameState);
	}
	
	public void destroyAll(GameState gameState) {
		for(EntityType_E type : EntityType_E.values()) {
			_EntityGroups.get(type).destroyAll(gameState);
		}
	}
	
	public void process(GameState gameState, int elapsed) {
		for(EntityType_E type : EntityType_E.values()) {
			_EntityGroups.get(type).process(gameState, elapsed);
		}
	}
	
	public EntityGroup_I getGroup(EntityType_E type) {
		return _EntityGroups.get(type);
	}
}